package constraint;

import java.util.List;

import common.MCore;
import common.MElement;

import expression.MIntVar;

public class MPredicate extends MElement {
	private String name;
	private String comment;
	private MConstraint constraint;
	private List<MIntVar> variables;

	public MPredicate(MCore core, String n, String c, MConstraint cst) {
		super(core);
		name = n;
		comment = c;
		constraint = cst;
		variables = cst.getVariables();
		for (MIntVar v: variables) {
			v.addPredicate(this);
		}
	}
	
	public String getName() {
		return name;
	}
	
	public String getComment() {
		return comment;
	}
	
	public MConstraint getConstraint() {
		return constraint;
	}

	public String toText() {
		return "predicate " + name + " [" + comment + "] : " + constraint.toString();
	}
	
	public String toString() {
		String s = "predicate " + name + " \t[" + comment + "] \t{ ";
		for (MIntVar v: getVariables()) {
			s += v.getName() + " ";
		}
		s += "} : " + constraint.toText();
		return s;
	}
	
	public List<MIntVar> getVariables() {
		return variables;
	}
}
